package servlets;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;

import shuyu.ArticleDao;

@WebServlet("/EditMessage")
public class EditMessage extends HttpServlet {
	@Override
	protected void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) 
			throws javax.servlet.ServletException ,java.io.IOException {
		req.setCharacterEncoding("utf-8");
		int id = Integer.parseInt(req.getParameter("id"));
		String title = req.getParameter("title");
		String context = req.getParameter("context");
		
		if (title != null && context != null) {
			ArticleDao articleDao = new ArticleDao();
			articleDao.editArticle(title, context, id);
		}
		
		resp.sendRedirect(req.getContextPath()+"/index.jsp");
	
	};

}
